import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:jet_rails/jr_app/jr_views/jr_video/jr_video_controller.dart';
import 'package:jet_rails/jr_app/jr_views/jr_video/jr_video_feed.dart';
import 'package:jet_rails/jr_app/jr_widgets/jr_app_bar.dart';
import 'package:jet_rails/jr_app/jr_widgets/jr_scaffold.dart';
import 'package:jet_rails/jr_services/jr_services.dart';
import 'package:jet_rails/jr_utils/jr_snippet.dart';

class JrVideoView extends StatefulWidget {
  const JrVideoView({Key? key}) : super(key: key);

  @override
  State<JrVideoView> createState() => _JrVideoViewState();
}

class _JrVideoViewState extends State<JrVideoView> {
  @override
  void initState() {
    Get.put(JrVideoController());
    super.initState();
  }

  @override
  void dispose() {
    Get.delete<JrVideoController>();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return JrScaffold(
      defaultTopPadding: false,
      appBar: JrAppBar(
        title: Row(
          children: [
            Image.asset('assets/images/icon_video.png', height: 24.h),
            Text('Video', style: TextStyle(fontSize: 24.h).merge(JrSnippets.commonTextStyle))
          ],
        ),
        mainViewStyle: true,
      ),
      body: Obx(() => JrVideoFeed(
          key: Key(JrServices.instance.availableVideo.length.toString()),
          videoModelList: JrServices.instance.availableVideo)),
    );
  }
}
